package com.yida.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.yida.service.blogRoll;

@Controller
public class blogroll {
	
	@Autowired
	blogRoll service;
	
	@RequestMapping("/blogroll")
	public String blogroll(Model mode) {
		 List<com.yida.bean.blogroll> blogRollList =  service.blogRoolAll();
		
		mode.addAttribute("list", blogRollList);
		return "blogroll";
	}
	
	@RequestMapping("/blogroll/add")
	@ResponseBody
	public Object blogroll(com.yida.bean.blogroll blogroll) {
		
		blogroll.setState(1);
		
		boolean result =  service.blogRoolAdd(blogroll);
		
		Map<String, String>  res = new HashMap<String, String>();
		
		if (!"false".equals(res)) {
			res.put("result", "true");	
		}else {
			 res.put("result", "false");
		}
		
		return res;
		
	
	}

}
